package com.lbmb.photodrawaimanager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lbmb.photodrawaimanager.common.Page;
import com.lbmb.photodrawaimanager.entity.dto.UserEntity;
import com.lbmb.photodrawaimanager.entity.req.UserReq;
import com.lbmb.photodrawaimanager.entity.resp.UserResp;
import com.lbmb.photodrawaimanager.mapper.UserMapper;
import com.lbmb.photodrawaimanager.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author hanWang
 * @Title:
 * @Package
 * @Description:
 * @date 2023/8/22:18 下午
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService {
    @Autowired
    UserMapper mapper;
    @Override
    public List<UserResp> getUser(UserReq req) {
        LambdaQueryWrapper<UserEntity> query = new LambdaQueryWrapper<>();
        query.eq(UserEntity::getId,req.getId());
        List<UserEntity> userEntities = mapper.selectList(query);

        return userEntities.stream().map(a->{
            UserResp resp = new UserResp();
            BeanUtils.copyProperties(a,resp);
            return resp;
        }).collect(Collectors.toList());

    }
}
